/*
 * Copyright (c) 2020 hebeiyiliuba.com
 * All rights reserved.
 *
 */
package org.jeecg.modules.middleware.redis.message.constant.enums;

import lombok.Getter;
import lombok.NoArgsConstructor;
import org.jeecg.modules.middleware.redis.message.service.BaseAbstraclListener;

/**
 * redis消息队列配置-订阅者
 * 采用枚举的方式定义管道RedisChannelEnums
 * @author duanlikao
 * @created 2021/7/17
 * @AllArgsConstructor
 */
@Getter
@NoArgsConstructor
public enum RedisChannelEnum {
//    TEST("test", RedisTestListener.class, "测试"),
    ;

    /**
     * 消息通道
     */
    private  String channel;
    /**
     * 接收消息服务
     */
    private Class<? extends BaseAbstraclListener> className;
    private  String msg;

    RedisChannelEnum(String channel, Class<? extends BaseAbstraclListener> className, String msg) {
         this.channel = channel;
         this.className=className;
         this.msg = msg;
    }

    public String getChannel() {
        return this.channel;
    }

    public String getDesc() {
        return this.msg;
    }

//    private static Map <String, RedisChannelEnum> channelMap = Maps.newHashMap();
//    public static String getMsg(String code) {
//        return channelMap.containsKey(code) ? channelMap.get(code).getDesc() : StringUtils.EMPTY;
//    }
//
//    public static boolean isValid(String channel) {
//        return channelMap.containsKey(channel);
//    }
//
//    static {
//        for (RedisChannelEnum status : RedisChannelEnum.values()) {
//            channelMap.put(status.getChannel(), status);
//        }
//    }

//    public static RedisChannelEnum getRedisChannelEnumByVal(String channel) {
//        return Arrays.stream(RedisChannelEnum.values()).collect(Collectors.toMap(
//                RedisChannelEnum::getChannel, value -> value, (k1, k2) -> k2)).get(channel);
//    }

    public Class<? extends BaseAbstraclListener> getClassName() {
                return className;
    }
}
